import 'package:flutter/material.dart';
import 'package:homepad/models/datetime_model.dart';
import 'package:homepad/styles.dart';
import 'package:provider/provider.dart';

class HomeWidgetCalendar extends StatelessWidget {
  const HomeWidgetCalendar({super.key});

  @override
  Widget build(BuildContext context) {
    final MyStyles styles = Theme.of(context).extension<MyStyles>()!;

    final List<Shadow> shadows = [
      const Shadow(
        blurRadius: 4.0,
        color: Color.fromARGB(60, 0, 0, 0),
        offset: Offset(2.0, 4.0),
      )
    ];

    var date = context.watch<DateTimeModel>().date;
    var weekday = context.watch<DateTimeModel>().weekday;
    var day = context.watch<DateTimeModel>().day;

    return Container(
      height: 225,
      width: 225,
      decoration: ShapeDecoration(
        shape: RoundedRectangleBorder(borderRadius: styles.radius),
        image: const DecorationImage(
          fit: BoxFit.fill,
          image: AssetImage("assets/images/bg_home_widget_calendar.jpg"),
        ),
      ),
      child: Container(
        color: styles.overlay,
        child: Stack(
          children: [
            Positioned(
                top: 20,
                left: 5,
                width: 220,
                child: Text(date, textAlign: TextAlign.center, style: styles.titleStyle.copyWith(
                  fontSize: 32,
                  shadows: shadows,
                ))),

            Positioned(
                top: 32,
                left: 0,
                width: 155,
                child:
                    Text(day, textAlign: TextAlign.right, style: styles.homeTimeTextStyle.copyWith(
                      fontSize: 140,
                      letterSpacing: -8,
                      shadows: shadows,
                    ))),
            Positioned(
                top: 74,
                right: 4,
                width: 55,
                child: Text("星\n期\n$weekday",
                    textAlign: TextAlign.center,
                    style: styles.titleStyle.copyWith(
                      fontFamily: "PingFangMedium",
                      fontSize: 32,
                      color: const Color.fromARGB(255, 255, 76, 57),
                      height: 1.25,
                      shadows: shadows,
                    )
                )),
          ],
        ),
      ),
    );
  }
}
